﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EzDesk.EzAppApi.Web.Utility.Extensions
{
    public static class StringForWebExtensions
    {            /// <summary>
        /// 将字符串裁剪成某个长度，裁剪后在最后加上"..."
        /// </summary>
        /// <param name="str"></param>
        /// <param name="count"></param>
        /// <lastReview>2009.11.20</lastReview>
        /// <returns></returns>
        public static string CutString(this String str, int count)
        {
            //特殊情况，裁剪到非常短
            if (count < 3)
            {
                return "...";
            };
            if (str.Length > count)
            {
                str = str.Substring(0, count - 3) + "...";
            }
            return str;
        }
    }
}